package com.qf.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class ConnUtil {


    public static Connection getConnection(){
        //1. 创建连接工厂
        ConnectionFactory factory = new ConnectionFactory();

        //2. 设置5个信息
        factory.setHost("192.168.11.11");
        factory.setPort(5672);
        factory.setUsername("2004");
        factory.setPassword("2004");
        factory.setVirtualHost("2004");

        //3. 从工厂获取连接对象
        Connection connection = null;
        try {
            connection = factory.newConnection();
        } catch (Exception e) {
            e.printStackTrace();
        }

        //4. 返回
        return connection;
    }

}
